<?php
//login.php

require_once 'includes/global.inc.php';

$error = "";
$username = "";
$password = "";

//check to see if they've submitted the login form
if(isset($_POST['submit-login'])) { 

	$username = $_POST['username'];
	$password = $_POST['password'];

	$userTools = new UserTools();
	if($userTools->login($username, $password)){
		//successful login, redirect them to a page
		header("Location: order.php");
	}else{
		$error = "<div class=\"notification error\">
					<a href=\"#\" class=\"close-notification\" title=\"Hide Notification\" rel=\"tooltip\">x</a>
					<p><strong>Error</strong> Wrong Password or Username.</p>
				</div>";
	}
}
?>
<!doctype html>
<!--[if IE 7 ]>    <html lang="en" class="no-js ie7"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="no-js ie8"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="no-js ie9"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html lang="en" class="no-js"> <!--<![endif]-->
<head>
	<meta charset="UTF-8">
	<title>Login | LaundryBox</title>
	<meta name="description" content="">
	<meta name="author" content="">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	
	<link rel="shortcut icon" href="favicon.ico">
	 
	
	<!-- CSS Styles -->
	<link rel="stylesheet" href="css/style.css">
	<link rel="stylesheet" href="css/colors.css">
	<link rel="stylesheet" href="css/jquery.tipsy.css">
	
	<!-- Google WebFonts -->
	<link href='css/font.css' rel='stylesheet' type='text/css'>
	
	<script src="js/libs/modernizr-1.7.min.js"></script>
</head>
<body class="login">
	<section role="main">
	
		<a href="#" title="Back to Homepage"></a>
	
		<!-- Login box -->
		<article id="login-box">
		
			<div class="article-container">
			
				<p>My Laundry Box login panel</p>
				
				<?php
					if($error != "")
					{
						echo $error."<br/>";
					}
				?>
			
				<form action="login.php" method="post">
					<fieldset>
						<dl>
							<dt>
								<label>Login</label>
							</dt>
							<dd>
								<input type="text" class="large" name="username" value="<?php echo $username; ?>">
							</dd>
							<dt>
								<label>Password</label>
							</dt>
							<dd>
								<input type="password" class="large" name="password" value="<?php echo $password; ?>">
							</dd>
							<dt>
								<label>Location</label>
							</dt>
							<dd>
								<select name="location">
									<option selected>Choose a Location</option>
									<option value="Black">Loc 1</option>
									<option value="White">Loc 2</option>
								</select>
							</dd>
							<dt class="checkbox"><label>Remeber me</label></dt>
							<dd><input type="checkbox"></dd>
						</dl>
					</fieldset>
					<button type="submit" class="right" value="Login" name="submit-login">Log in</button>
				</form>
			
			</div>
		
		</article>
		<!-- /Login box -->
		<ul class="login-links">
			<li><a href="#">Lost password?</a></li>
			<li><a href="#">Enlliance</a></li>
		</ul>
		
	</section>

	<!-- JS Libs at the end for faster loading -->
	<script src="js/jquery/jquery.min.js"></script>
	<script>!window.jQuery && document.write(unescape('%3Cscript src="js/jquery/jquery-1.5.1.min.js"%3E%3C/script%3E'))</script>
	<script src="js/libs/selectivizr.js"></script>
	<script src="js/jquery/jquery.tipsy.js"></script>
	<script src="js/login.js"></script>
</body>
</html>